﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CarLoanSystem.Entity;

namespace CarLoanSystem
{
    public partial class frmAddCarModel : Form
    {
        public frmAddCarModel()
        {
            InitializeComponent();
            this.cbbCarBrand.DataSource = DAL.CarBrandInfoDAL.LoadAllForComboBox();
            this.cbbCarBrand.DisplayMember = "CAR_BRAND_NAME";
            this.cbbCarBrand.ValueMember = "CAR_BRAND_ID";
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            CarModelItem carModelItem = new CarModelItem();
            carModelItem.CAR_BRAND_ID = Convert.ToInt32(this.cbbCarBrand.SelectedValue.ToString());
            carModelItem.CAR_MODEL_NAME = this.txtModelName.Text;
            DAL.CarModelInfoDAL.Insert(carModelItem);
            MessageBox.Show("บันทึกข้อมูลเรียบร้อย", "ข้อมูลรุ่นรถยนต์");
            this.Close();
        }
    }
}
